// 支付产品Mock数据
export interface PaymentProduct {
  productId: string
  productName: string
  productCode: string
  productType: string
  productDesc: string
  minAmount: number
  maxAmount: number
  status: number
  createdTime: string
  updatedTime: string
}

export const paymentProducts: PaymentProduct[] = [
  {
    productId: 'PROD001',
    productName: '微信扫码支付',
    productCode: 'WXPAY_NATIVE',
    productType: 'NATIVE',
    productDesc: '用户扫描商户二维码完成支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 1,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD002',
    productName: '微信APP支付',
    productCode: 'WXPAY_APP',
    productType: 'APP',
    productDesc: '移动应用内调起微信支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 1,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD003',
    productName: '微信JSAPI支付',
    productCode: 'WXPAY_JSAPI',
    productType: 'JSAPI',
    productDesc: '微信公众号内支付，用户在微信内打开商户网页，商户在网页内调起微信支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 1,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD004',
    productName: '微信H5支付',
    productCode: 'WXPAY_H5',
    productType: 'H5',
    productDesc: '手机网页端微信支付',
    minAmount: 0.01,
    maxAmount: 60000,
    status: 1,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD005',
    productName: '支付宝扫码支付',
    productCode: 'ALIPAY_NATIVE',
    productType: 'NATIVE',
    productDesc: '用户扫描商户二维码完成支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 1,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD006',
    productName: '支付宝APP支付',
    productCode: 'ALIPAY_APP',
    productType: 'APP',
    productDesc: '移动应用内调起支付宝支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 1,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD007',
    productName: '支付宝JSAPI支付',
    productCode: 'ALIPAY_JSAPI',
    productType: 'JSAPI',
    productDesc: '支付宝小程序内支付，支持生活号场景',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 1,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD008',
    productName: '支付宝H5支付',
    productCode: 'ALIPAY_H5',
    productType: 'H5',
    productDesc: '手机网页端支付宝支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 1,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD009',
    productName: '银联扫码支付',
    productCode: 'UNIONPAY_NATIVE',
    productType: 'NATIVE',
    productDesc: '银联二维码支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 0,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD010',
    productName: '银联APP支付',
    productCode: 'UNIONPAY_APP',
    productType: 'APP',
    productDesc: '银联APP支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 0,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  },
  {
    productId: 'PROD011',
    productName: '银联刷卡支付',
    productCode: 'UNIONPAY_CARD',
    productType: 'CARD',
    productDesc: '银联刷卡支付',
    minAmount: 0.01,
    maxAmount: 50000,
    status: 0,
    createdTime: '2024-01-01 10:00:00',
    updatedTime: '2024-01-15 10:00:00'
  }
]

// 产品类型枚举
export const ProductType = {
  NATIVE: 'NATIVE',    // 扫码支付
  APP: 'APP',          // APP支付
  JSAPI: 'JSAPI',      // 小程序支付
  H5: 'H5',            // H5支付
  CARD: 'CARD'         // 刷卡支付
}

// 产品状态枚举
export const ProductStatus = {
  DISABLED: 0,         // 禁用
  ENABLED: 1,          // 启用
  TESTING: 2,          // 测试中
  MAINTENANCE: 3,      // 维护中
  DEPRECATED: 4        // 已废弃
}

// 获取产品类型名称
export const getProductTypeName = (type: string): string => {
  const typeMap: { [key: string]: string } = {
    NATIVE: '扫码支付',
    APP: 'APP支付',
    JSAPI: 'JSAPI支付',
    H5: 'H5支付',
    CARD: '刷卡支付'
  }
  return typeMap[type] || type
}

// 获取产品类型颜色
export const getProductTypeColor = (type: string): string => {
  const colorMap: { [key: string]: string } = {
    NATIVE: 'blue',
    APP: 'green',
    JSAPI: 'orange',
    H5: 'purple',
    CARD: 'red'
  }
  return colorMap[type] || 'default'
}

// 获取产品状态名称
export const getProductStatusName = (status: number): string => {
  const statusMap: { [key: number]: string } = {
    0: '禁用',
    1: '启用',
    2: '测试中',
    3: '维护中',
    4: '已废弃'
  }
  return statusMap[status] || '未知'
}

// 获取产品状态颜色
export const getProductStatusColor = (status: number): string => {
  const colorMap: { [key: number]: string } = {
    0: 'error',
    1: 'success',
    2: 'processing',
    3: 'warning',
    4: 'default'
  }
  return colorMap[status] || 'default'
}

// 按类型分组产品
export const groupProductsByType = (products: PaymentProduct[]) => {
  const grouped = products.reduce((acc, product) => {
    const type = product.productType
    if (!acc[type]) {
      acc[type] = []
    }
    acc[type].push(product)
    return acc
  }, {} as { [key: string]: PaymentProduct[] })

  return grouped
}